unit MessageBox;

interface

uses
  Winapi.Windows, Winapi.Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIForm, uniGUIBaseClasses, uniButton, uniBitBtn, StdCtrls,
  uniLabel, dxGDIPlusClasses, jpeg, uniImage, ClientRowSet, uniMemo;

type
  TMessageBoxCallBack = procedure(crsFrom: TClientRowSet);
  TFrmMessageBox = class(TUniForm)
    btLogin: TUniBitBtn;
    UniImage8: TUniImage;
    image1: TUniImage;
    lbInfo: TUniLabel;
    btnCancel: TUniBitBtn;
    btnLogin_1: TUniBitBtn;
    procedure btLoginClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
    procedure UniFormCreate(Sender: TObject);
  private
    { Private declarations }
    FDataSet: TClientRowSet;
    procedure ConfirmEvent(Sender: TObject);
    procedure ConfirmEventProc(Sender: TObject);
  public
    { Public declarations }
    procedure ShowInfo(caption:String);
    procedure ShowInfoProc(caption: string; CallBackProc: TMessageBoxCallBack; ADataSet: TClientRowSet);
  end;
var
  FCallBackProc: TMessageBoxCallBack;

function FrmMessageBox: TFrmMessageBox;

implementation

{$R *.dfm}

uses
  MainModule, ExpModule, uCommFunction;

function FrmMessageBox: TFrmMessageBox;
begin
  Result := TFrmMessageBox(UniMainModule.GetFormInstance(TFrmMessageBox));
end;

procedure TFrmMessageBox.btLoginClick(Sender: TObject);
begin
  self.close;
end;

procedure TFrmMessageBox.btnCancelClick(Sender: TObject);
begin
  Self.Close;
end;

procedure TFrmMessageBox.ConfirmEvent(Sender: TObject);
begin
  Self.Close;
end;

procedure TFrmMessageBox.ConfirmEventProc(Sender: TObject);
begin
  Self.Close;
  if Assigned(FCallBackProc) then
    FCallBackProc(FDataSet);
end;

procedure TFrmMessageBox.ShowInfo(caption: String);
begin
  if dmExpress.UserInfo.isPcModel then
    lbInfo.Font.Color := clBlack
  else
    lbInfo.Font.Color := clWhite;
  btLogin.Visible := True;
  lbinfo.Caption := caption;
  btLogin.OnClick := ConfirmEvent;
  self.ShowModal;
end;

procedure TFrmMessageBox.ShowInfoProc(caption: string;
  CallBackProc: TMessageBoxCallBack; ADataSet: TClientRowSet);
begin
  if dmExpress.UserInfo.isPcModel then
    lbInfo.Font.Color := clBlack
  else
    lbInfo.Font.Color := clWhite;
  btnLogin_1.Visible := True;
  lbinfo.Caption := caption;
  FCallBackProc := CallBackProc;
  FDataSet := ADataSet;
  btnLogin_1.OnClick := ConfirmEventProc;
  btnCancel.Visible := True;
  self.ShowModal;
end;

procedure TFrmMessageBox.UniFormCreate(Sender: TObject);
begin
  SetCompoentLanguage(Self);
end;

end.
